@use '../../internals/Box/styles/index' as box;

//
// List
// --------------------------------------------------

.rs-list {
  --rs-list-border-width: 1px;

  position: relative;
  overflow-x: hidden;
  overflow-y: auto;

  &[data-bordered='true'] {
    border-radius: var(--rs-radius-md);
    border: var(--rs-list-border-width) solid var(--rs-list-border);
  }

  &[data-hover='true'] .rs-list-item:hover {
    background-color: var(--rs-list-hover-bg);
  }

  &[data-sortable='true'] .rs-list-item {
    cursor: move; // fallback on IE 11
    cursor: grab;

    &-disabled,
    &-disabled:active {
      cursor: not-allowed;
    }
  }
}

// default list item ( axis-y )
.rs-list-item {
  position: relative;

  &[data-bordered='true'] {
    padding-inline-start: 20px;
    padding-inline-end: 20px;
  }

  &[data-size='lg'] {
    padding-top: 20px;
    padding-bottom: 20px;
  }

  &[data-size='md'] {
    padding-top: 13px;
    padding-bottom: 13px;
  }

  &[data-size='sm'] {
    padding-top: 8px;
    padding-bottom: 8px;
  }

  &[data-size='xs'] {
    padding-top: 2px;
    padding-bottom: 2px;
  }
}

.rs-list-item {
  background-color: var(--rs-list-bg);

  &-helper {
    position: absolute;
    background-color: var(--rs-list-bg);
    box-shadow: var(--rs-shadow-sm);
    width: calc(100% - 2px);
    border-radius: var(--rs-radius-md);
    top: 0;
    inset-inline-start: 0;
    z-index: var(--rs-zindex-list-helper);
    border: none;
    cursor: move;

    // Increase z-index when modal opened.
    .rs-modal-open & {
      z-index: calc(var(--rs-zindex-modal) + var(--rs-zindex-list-helper));
    }

    // Increase z-index when drawer opened.
    .rs-drawer-open & {
      z-index: calc(var(--rs-zindex-drawer) + var(--rs-zindex-list-helper));
    }
  }

  &-holder {
    background-color: var(--rs-list-placeholder-bg);
    visibility: hidden;

    &::after {
      content: '';
      position: absolute;
      visibility: visible;
      top: var(--rs-list-border-width);
      inset-inline-start: var(--rs-list-border-width);
      width: calc(100% - 2 * var(--rs-list-border-width));
      height: calc(100% - 2 * var(--rs-list-border-width));
      border: var(--rs-list-border-width) var(--rs-list-placeholder-border) dashed;
    }
  }
}

.rs-list[data-divider='true'] {
  .rs-list-item + .rs-list-item {
    border-top: var(--rs-list-border-width) solid var(--rs-list-border);
  }
}
